#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int N = 1e6 + 10;

vector<vector<int>> div(vector<int> &A, const int &B)
{
    vector<int> C;
    int t = 0;
    for (int i = A.size() - 1; i >= 0; i--)
    {
        t = t * 10 + A.at(i);
        C.push_back(t / B);
        t %= B;
    }
    while (C.size() > 1 && *C.begin() == 0)
        C.erase(C.begin());
    return {{C.rbegin(), C.rend()}, {t}};
}

int main(void)
{
    vector<int> A;
    string a;
    int B;
    cin >> a >> B;

    for (auto x = a.rbegin(); x != a.rend(); x++)
        A.push_back(*x - '0');

    auto C = div(A, B);
    for (int i = C.at(0).size() - 1; i >= 0; i--)
        cout << C.at(0).at(i);
    cout << '\n'
         << C.at(1).at(0) << endl;
}